package sdfi.lee.Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sdfi.lee.DAO.RolltypeDAO;
import sdfi.lee.Entity.Rollnotice;

/**
 * Servlet implementation class GetRolltype
 */
public class GetRollnotice extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GetRollnotice() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String typeid=request.getParameter("type");
		String keyword=request.getParameter("kw");
		//System.out.println(keyword);
		response.setCharacterEncoding("utf-8");
		StringBuffer sb=new StringBuffer("");
		List<Rollnotice> list=new RolltypeDAO().getRollnotice(1,10, Integer.valueOf(typeid).intValue(), keyword);
		if(list==null||list.size()<=0) sb.append("暂无此类资源");
		else
		{
			for(Rollnotice notice:list)
			{
				sb.append("<div>");
				sb.append("<a href='#' path='"+notice.getRollpath()+"'>");
				sb.append(notice.getRolltitle());
				sb.append("</a>");
				sb.append("</div>");
			
			}
		
		}
		sb.append("");
		//System.out.println(sb.toString());
		PrintWriter pw=response.getWriter();
		pw.append(sb.toString());
		pw.flush();
		pw.close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(request, response);
	}

}
